import torch
from diffusers import StableDiffusionPipeline, UniPCMultistepScheduler

pipe = StableDiffusionPipeline.from_pretrained(
    "C:/Users/Administrator/Downloads/revAnimated_v122",
    safety_checker=None
    # revision="fp16",
    # custom_pipeline="lpw_stable_diffusion",
    # local_files_only=True,
    # torch_dtype=torch.float16,
    # use_auth_token=True
)
import os
os.environ['CURL_CA_BUNDLE'] = ''
# パイプラインの準備
pipe.scheduler = UniPCMultistepScheduler.from_config(pipe.scheduler.config)

pipe.enable_xformers_memory_efficient_attention()
# pipe.enable_attention_slicing()
pipe.enable_vae_slicing()
pipe.enable_attention_slicing(1)
pipe.enable_sequential_cpu_offload()
# pipe.enable_attention_slicing("max")
pipe.vae.enable_tiling()

# 推論の実行
prompt = "((best quality)), ((masterpiece)), (detailed), woman with green hair, holding a sword, (Artgerm inspired:1.2), (pixiv contest winner:1.1), (octopus goddess:1.3), (Berserk art style:1.2), close-up portrait, goddess skull, (Senna from League of Legends:1.1), (Tatsumaki with green curly hair:1.2), card game illustration, thick brush, HD anime wallpaper, (Akali from League of Legends:1.1), 8k resolution"
negative_prompt = "3d, cartoon, anime, sketches, (worst quality, bad quality, child, cropped:1.4) ((monochrome)), ((grayscale)),  (bad-hands-5:1.0), (badhandv4:1.0), (easynegative:0.8),  (bad-artist-anime:0.8), (bad-artist:0.8), (bad_prompt:0.8), (bad-picture-chill-75v:0.8), (bad_prompt_version2:0.8),  (bad_quality:0.8)"

image = pipe(
    prompt, 
    width=4096,
    height=2048,
    num_inference_steps=10
).images[0]
# 当前时间 yyyy-mm-dd-hh-mm-ss
import datetime
now = datetime.datetime.now()
# 转换为指定的格式:
otherStyleTime = now.strftime("%Y-%m-%d-%H-%M-%S")
image.save("../data/4k_landscape" + otherStyleTime + ".png")